<?php

use Illuminate\Support\Facades\Route;

Route::group(['namespace' => '\App\Http\Controllers\Payment', 'prefix' => 'payment'], function () {

    //admin

    Route::resource('channel', 'ChannelController')->middleware(['auth:admin', 'check.parking_lot', 'permission:parking-lot.manage.setting.payment.channel'])->only(['index', 'store', 'show', 'destroy']);
    Route::resource('scene', 'SceneController')->middleware(['auth:admin', 'check.parking_lot', 'permission:parking-lot.manage.setting.payment.channel'])->only(['index', 'store']);
    Route::get('scenes', 'SceneController@all');

    // 支付回调通知
    Route::any('notify/paid/{payType}/{paymentChannelID}', 'NotifyController@paid');

    Route::get('payType/all', 'PayTypeController@all');

    //app

    Route::get('get_available_channels', 'ChannelController@getAvailableChannels');
    Route::post('tradePay', 'ChannelController@tradePay');
    Route::post('payResult', 'ChannelController@payResult');

    Route::group(['prefix' => 'invoice'], function () {

        Route::get('aggregate', 'InvoiceController@aggregate')->middleware(['auth:admin', 'check.parking_lot']);
        //app && PC
        Route::get('detail/{id}', 'InvoiceController@show');
        Route::post('issue', 'InvoiceController@issue');
        Route::post('/', 'InvoiceController@index');

        Route::any('notify/{type}/{act}', 'NotifyController@invoice');
        Route::resource('subject', 'InvoiceSubjectController')->middleware(['auth:admin', 'check.parking_lot', 'permission:parking-lot.manage.setting.invoice.subject'])->only(['index', 'store', 'show', 'destroy']);
        Route::resource('good_detail', 'GoodDetailController')->middleware(['auth:admin', 'check.parking_lot', 'permission:parking-lot.manage.setting.invoice.item'])->only(['index', 'store', 'show', 'destroy']);
        //app
        Route::resource('title', 'InvoiceTitleController')->middleware(['auth:app'])->only(['index', 'store', 'show', 'destroy']);
    });

    Route::post('refundOrder/list', 'RefundController@index')->middleware(['auth:admin']); // 'check.parking_lot'
    Route::post('refundOrder/export', 'RefundController@export')->middleware(['auth:admin']);
    Route::post('refund/{orderPaidCode}', 'RefundController@toRefund')->middleware(['auth:admin']);
});
